﻿using System;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.nodes.mssql;

namespace SharpSqlAnalyzer.stmt.mssql
{
	// Token: 0x0200017B RID: 379
	public class TMssqlIfElse : TCustomSqlStatement
	{
		// Token: 0x06000D33 RID: 3379 RVA: 0x00308643 File Offset: 0x00306843
		public TMssqlIfElse(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstmssqlif;
		}

		// Token: 0x06000D34 RID: 3380 RVA: 0x0030865B File Offset: 0x0030685B
		internal override void buildsql()
		{
		}

		// Token: 0x06000D35 RID: 3381 RVA: 0x0030865D File Offset: 0x0030685D
		internal override void clear()
		{
		}

		// Token: 0x06000D36 RID: 3382 RVA: 0x0030865F File Offset: 0x0030685F
		internal override string getasprettytext()
		{
			return "";
		}

		// Token: 0x06000D37 RID: 3383 RVA: 0x00308666 File Offset: 0x00306866
		internal virtual void iterate(TVisitorAbs pvisitor)
		{
		}

		// Token: 0x1700026A RID: 618
		// (get) Token: 0x06000D38 RID: 3384 RVA: 0x00308668 File Offset: 0x00306868
		// (set) Token: 0x06000D39 RID: 3385 RVA: 0x00308670 File Offset: 0x00306870
		public virtual TCustomSqlStatement ElseStmt
		{
			get
			{
				return this.elseStmt;
			}
			set
			{
				this.elseStmt = value;
			}
		}

		// Token: 0x1700026B RID: 619
		// (get) Token: 0x06000D3A RID: 3386 RVA: 0x00308679 File Offset: 0x00306879
		// (set) Token: 0x06000D3B RID: 3387 RVA: 0x00308681 File Offset: 0x00306881
		public virtual TCustomSqlStatement Stmt
		{
			get
			{
				return this.stmt;
			}
			set
			{
				this.stmt = value;
			}
		}

		// Token: 0x1700026C RID: 620
		// (get) Token: 0x06000D3C RID: 3388 RVA: 0x0030868A File Offset: 0x0030688A
		// (set) Token: 0x06000D3D RID: 3389 RVA: 0x00308692 File Offset: 0x00306892
		public virtual TExpression Condition
		{
			get
			{
				return this.condition;
			}
			set
			{
				this.condition = value;
			}
		}

		// Token: 0x1700026D RID: 621
		// (get) Token: 0x06000D3E RID: 3390 RVA: 0x0030869B File Offset: 0x0030689B
		// (set) Token: 0x06000D3F RID: 3391 RVA: 0x003086A3 File Offset: 0x003068A3
		public virtual TMssqlCreateTriggerUpdateColumnList UpdateColumnList
		{
			get
			{
				return this.updateColumnList;
			}
			set
			{
				this.updateColumnList = value;
			}
		}

		// Token: 0x1700026E RID: 622
		// (get) Token: 0x06000D40 RID: 3392 RVA: 0x003086AC File Offset: 0x003068AC
		// (set) Token: 0x06000D41 RID: 3393 RVA: 0x003086B4 File Offset: 0x003068B4
		public virtual int StmtType
		{
			get
			{
				return this.stmtType;
			}
			set
			{
				this.stmtType = value;
			}
		}

		// Token: 0x06000D42 RID: 3394 RVA: 0x003086C0 File Offset: 0x003068C0
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			TIfSqlNode tifSqlNode = (TIfSqlNode)this.rootNode;
			base.doParseStatement(psql);
			this.stmtType = tifSqlNode.StmtType;
			this.condition = tifSqlNode.Condition;
			if (this.condition != null)
			{
				this.condition.doParse(this, ESqlClause.unknown);
			}
			this.updateColumnList = tifSqlNode.UpdateColumnList;
			if (this.updateColumnList != null)
			{
				for (int i = 0; i < this.updateColumnList.size(); i++)
				{
					if (psql.AncestorStmt.sqlstatementtype == ESqlStatementType.sstmssqlcreatetrigger)
					{
						psql.AncestorStmt.tables.getTable(0).LinkedColumns.addObjectName(this.updateColumnList.getCreateTriggerUpdateColumn(i).ColumnName);
						this.updateColumnList.getCreateTriggerUpdateColumn(i).ColumnName.SourceTable = psql.AncestorStmt.tables.getTable(0);
					}
				}
			}
			tifSqlNode.StmtSqlNode.doParse(this, ESqlClause.unknown);
			this.stmt = tifSqlNode.StmtSqlNode.Stmt;
			base.endToken = this.stmt.endToken;
			if (tifSqlNode.ElseStmtSqlNode != null)
			{
				tifSqlNode.ElseStmtSqlNode.doParse(this, ESqlClause.unknown);
				this.elseStmt = tifSqlNode.ElseStmtSqlNode.Stmt;
				base.endToken = this.elseStmt.endToken;
			}
			return 0;
		}

		// Token: 0x06000D43 RID: 3395 RVA: 0x0030880B File Offset: 0x00306A0B
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06000D44 RID: 3396 RVA: 0x0030881C File Offset: 0x00306A1C
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.condition != null)
			{
				this.condition.acceptChildren(v);
			}
			this.stmt.accept(v);
			if (this.elseStmt != null)
			{
				this.elseStmt.acceptChildren(v);
			}
			v.postVisit(this);
		}

		// Token: 0x04001302 RID: 4866
		private int stmtType = 1;

		// Token: 0x04001303 RID: 4867
		private TExpression condition;

		// Token: 0x04001304 RID: 4868
		private TMssqlCreateTriggerUpdateColumnList updateColumnList;

		// Token: 0x04001305 RID: 4869
		private TCustomSqlStatement stmt;

		// Token: 0x04001306 RID: 4870
		private TCustomSqlStatement elseStmt;
	}
}
